package com.ddtech.business.practice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ddtech.business.practice.entity.PracticeVrRecordStudent;
import com.ddtech.business.practice.mapper.PracticeVrRecordStudentMapper;
import com.ddtech.business.practice.service.PracticeVrRecordStudentService;
import com.ddtech.business.practice.vo.PracticeVrRecordStudentVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @version v1.0
 * @ClassName:PracticeVrRecordStudentServiceImpl description：
 * @author:wei_zhang(xiao)
 * @date: 2024-07-16 22:43
 */
@Service
public class PracticeVrRecordStudentServiceImpl extends ServiceImpl<PracticeVrRecordStudentMapper, PracticeVrRecordStudent> implements PracticeVrRecordStudentService {

    @Resource
    private PracticeVrRecordStudentMapper  practiceVrRecordStudentMapper;

    @Override
    public void savePracticeVrRecordStudent(String practiceId, List<PracticeVrRecordStudent> studentList) {
        for(PracticeVrRecordStudent practiceVrRecordStudent : studentList){
            practiceVrRecordStudent.init();
            practiceVrRecordStudent.setPracticeVrRecordId(practiceId);
            this.save(practiceVrRecordStudent);
        }
    }

    @Override
    public List<PracticeVrRecordStudentVo> list(String practiceId) {
        LambdaQueryWrapper<PracticeVrRecordStudent> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PracticeVrRecordStudent::getPracticeVrRecordId, practiceId);
        List<PracticeVrRecordStudentVo> list= this.list(queryWrapper).stream().map(
                item -> new PracticeVrRecordStudentVo(item.getStudentNumber(),item.getBonesName(),item.getStudentName(),
                        item.getScore(),item.getTeacherScore(), item.getKeyActionScore(),item.getPracticeDanceFile(),"")
        ).collect(Collectors.toList());
        return list;
    }

    @Override
    public List<PracticeVrRecordStudentVo> getList(String practiceId) {
        return practiceVrRecordStudentMapper.getData(practiceId);
    }
}
